﻿--[[
   @brief    login_popup_tips_model
   @author   maxyao, charleycao
   @version  1.0
   @date     2017-03-23
--]]

login_popup_tips_model =
{
    uin = 0;
    dlg_id = Tenio.INVALID_CONTROLID;
    dlg_ptr = nil;
    show_dlg = false;
    page_url = LoadStr("LOGIN_POPUP_TIPS_URL");
    ad_expose_url = LoadStr("LOGIN_AD_EXPLOSE_URL");
    ad_like_url = LoadStr("LOGIN_AD_LIKE_URL");
    ad_click_url = LoadStr("LOGIN_AD_CLICK_URL");
    
    ad_system_report_data = nil;
    need_show_login_popup_tips_guide = false;
    report_sub_id = 10001;
    tips_title = nil;
    tips_content = nil;
    tips_page_curr = 1;
    tips_page_count = 0;
    tips_total_count = 0;
    max_show_count = 9;     -- UI框架titlebar多于10个广告会错位
    tips_id = 0;
    tips_type_id = 5000;
    switch_time = 300000;
    game_running_state = 0;
    waiting_login_tips_data = nil;
    waiting_login_tips_show = nil;
    window_is_show = nil;
    reset_dislike_detail_broadcast = "i_broadcast_reset_login_popup_dislike_detail";
    finish_initilization_broadcast = "i_broadcast_finish_initilization";
    window_exists = false;
    show_directly = false;

    focus_banner_ = 0;

    rsp_tips_data_ = nil;
    has_user_guide_ = nil;

    init = function()
        local server = base_utility.get_debug_value("login_popup_tips", "server", 0);
        if server ~= 1 then
            login_popup_tips_model.page_url = LoadStr("LOGIN_POPUP_TIPS_LOCAL_URL");
        end
        local direct = base_utility.get_debug_value("login_popup_tips", "direct", 0);
        if direct == 1 then
            login_popup_tips_model.show_directly = true;
        end
    end;

    reconstruct_content = function (tips_content)
        local rec_content = {}
        if tips_content ~= nil and type(tips_content) == "table" then
            for idx, ad_data in ipairs(tips_content) do
                local pos_id = ad_data.child_pos_id;
                local ads_info = ad_data.ads_info;
                if pos_id ~= nil and ads_info ~= nil then
                    ads_info["pos_id"] = pos_id;    -- 添加冗余字段
                    rec_content[pos_id] = ads_info;
                end 
            end
        end
        return rec_content;
    end;

};

login_popup_tips_model.init();